﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QueryData;

public class 查询集合
{
    void MyMethod()
    {
        using (var db = new BasicDbContext())
        {
            // 查询全部记录
            db.BasicEntities.ToList();
            // 查询Text列以keyword开头的记录
            db.BasicEntities.Where(x => x.Text.StartsWith("keyword")).ToList();
            // 按Id升序排列查询全部记录
            db.BasicEntities.OrderBy(x => x.Id).ToList();
            // 按Id降序然后按Text升序排列查询全部记录
            db.BasicEntities.OrderByDescending(x => x.Id).ThenBy(x => x.Text).ToList();
            // 跳过前10条记录然后查询接下来的10条记录，但返回的是数组
            db.BasicEntities.Skip(10).Take(10).ToList();

        }
    }

}
